﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PresentationTier
{
    public partial class ParentForm : Form
    {
        private int childFormNumber = 0;

        //Form variables.
        private ArtistsForm artistsForm;   
        private ProjectsForm projectsForm;
        private TracksForm tracksForm;
        private ManagersForm managersForm;
        private EventsForm eventsForm;
        private StudiosForm studiosForm;
        private ContractsForm contractsForm;
        private MerchandiseForm merchandiseForm;
        private GetSalesDataForm getSalesDataForm;
        private TrackSalesForm trackSalesForm;

        public ParentForm()
        {
            InitializeComponent();
        }

        private void ShowNewForm(object sender, EventArgs e)
        {
            Form childForm = new Form();
            childForm.MdiParent = this;
            childForm.Text = "Window " + childFormNumber++;
            childForm.Show();
        }

        private void OpenFile(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            openFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
            if (openFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                string FileName = openFileDialog.FileName;
            }
        }

        private void SaveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();
            saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            saveFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
            if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                string FileName = saveFileDialog.FileName;
            }
        }

        private void ExitToolsStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void CutToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void CopyToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void PasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }

        private void StatusBarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            statusStrip.Visible = statusBarToolStripMenuItem.Checked;
        }

        private void CascadeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.Cascade);
        }

        private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileVertical);
        }

        private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileHorizontal);
        }

        private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.ArrangeIcons);
        }

        private void CloseAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form childForm in MdiChildren)
            {
                childForm.Close();
            }
        }

        private void artistsButton_Click(object sender, EventArgs e)
        {
            //If the form has not been open or has been closed. Initialize the Form.
            if (artistsForm == null || artistsForm.IsDisposed)
            {
                artistsForm = new ArtistsForm();
                artistsForm.MdiParent = this;
                artistsForm.WindowState = FormWindowState.Maximized;
                artistsForm.Show();
            }
            //If the form is minimized, maximise the Form.
            else if (artistsForm.WindowState == FormWindowState.Minimized)
            {
                artistsForm.WindowState = FormWindowState.Maximized;
            }
            //Bring the Form to the Front.
            artistsForm.BringToFront();   
        }

        private void projectsButton_Click(object sender, EventArgs e)
        {
            //If the form has not been open or has been closed. Initialize the Form.
            if (projectsForm == null || projectsForm.IsDisposed)
            {
                projectsForm = new ProjectsForm();
                projectsForm.MdiParent = this;
                projectsForm.WindowState = FormWindowState.Maximized;
                projectsForm.Show();
            }
            //If the form is minimized, maximise the Form.
            else if (projectsForm.WindowState == FormWindowState.Minimized)
            {
                projectsForm.WindowState = FormWindowState.Maximized;
            }
            //Bring the Form to the Front.
            projectsForm.BringToFront();
        }

        private void tracksButton_Click(object sender, EventArgs e)
        {
            //If the form has not been open or has been closed. Initialize the Form.
            if (tracksForm == null || tracksForm.IsDisposed)
            {
                tracksForm = new TracksForm();
                tracksForm.MdiParent = this;
                tracksForm.WindowState = FormWindowState.Maximized;
                tracksForm.Show();
            }
            //If the form is minimized, maximise the Form.
            else if (tracksForm.WindowState == FormWindowState.Minimized)
            {
                tracksForm.WindowState = FormWindowState.Maximized;
            }
            //Bring the Form to the Front.
            tracksForm.BringToFront();

        }

        private void managersButton_Click(object sender, EventArgs e)
        {
            //If the form has not been open or has been closed. Initialize the Form.
            if (managersForm == null || managersForm.IsDisposed)
            {
                managersForm = new ManagersForm();
                managersForm.MdiParent = this;
                managersForm.WindowState = FormWindowState.Maximized;
                managersForm.Show();
            }
            //If the form is minimized, maximise the Form.
            else if (managersForm.WindowState == FormWindowState.Minimized)
            {
                managersForm.WindowState = FormWindowState.Maximized;
            }
            //Bring the Form to the Front.
            managersForm.BringToFront();
        }

        private void EventsButton_Click(object sender, EventArgs e)
        {
            //If the form has not been open or has been closed. Initialize the Form.
            if (eventsForm == null || eventsForm.IsDisposed)
            {
                eventsForm = new EventsForm();
                eventsForm.MdiParent = this;
                eventsForm.WindowState = FormWindowState.Maximized;
                eventsForm.Show();
            }
            //If the form is minimized, maximise the Form.
            else if (eventsForm.WindowState == FormWindowState.Minimized)
            {
                eventsForm.WindowState = FormWindowState.Maximized;
            }
            //Bring the Form to the Front.
            eventsForm.BringToFront();
        }

        private void studioButton_Click(object sender, EventArgs e)
        {
            //If the form has not been open or has been closed. Initialize the Form.
            if (studiosForm == null || studiosForm.IsDisposed)
            {
                studiosForm = new StudiosForm();
                studiosForm.MdiParent = this;
                studiosForm.WindowState = FormWindowState.Maximized;
                studiosForm.Show();
            }
            //If the form is minimized, maximise the Form.
            else if (studiosForm.WindowState == FormWindowState.Minimized)
            {
                studiosForm.WindowState = FormWindowState.Maximized;
            }
            //Bring the Form to the Front.
            studiosForm.BringToFront();
        }

        private void ContractsButton_Click(object sender, EventArgs e)
        {
            //If the form has not been open or has been closed. Initialize the Form.
            if (contractsForm == null || contractsForm.IsDisposed)
            {
                contractsForm = new ContractsForm();
                contractsForm.MdiParent = this;
                contractsForm.WindowState = FormWindowState.Maximized;
                contractsForm.Show();
            }
            //If the form is minimized, maximise the Form.
            else if (contractsForm.WindowState == FormWindowState.Minimized)
            {
                contractsForm.WindowState = FormWindowState.Maximized;
            }
            //Bring the Form to the Front.
            contractsForm.BringToFront();
        }

        private void MerchandiseButton_Click(object sender, EventArgs e)
        {
            //If the form has not been open or has been closed. Initialize the Form.
            if (merchandiseForm == null || merchandiseForm.IsDisposed)
            {
                merchandiseForm = new MerchandiseForm();
                merchandiseForm.MdiParent = this;
                merchandiseForm.WindowState = FormWindowState.Maximized;
                merchandiseForm.Show();
            }
            //If the form is minimized, maximise the Form.
            else if (merchandiseForm.WindowState == FormWindowState.Minimized)
            {
                merchandiseForm.WindowState = FormWindowState.Maximized;
            }
            //Bring the Form to the Front.
            merchandiseForm.BringToFront();
        }

        private void importDataButton_Click(object sender, EventArgs e)
        {
            //If the form has not been open or has been closed. Initialize the Form.
            if (getSalesDataForm == null || getSalesDataForm.IsDisposed)
            {
                getSalesDataForm = new GetSalesDataForm();
                getSalesDataForm.MdiParent = this;
                getSalesDataForm.WindowState = FormWindowState.Maximized;
                getSalesDataForm.Show();
            }
            //If the form is minimized, maximise the Form.
            else if (getSalesDataForm.WindowState == FormWindowState.Minimized)
            {
                getSalesDataForm.WindowState = FormWindowState.Maximized;
            }
            //Bring the Form to the Front.
            getSalesDataForm.BringToFront();
        }

        private void trackSalesButton_Click(object sender, EventArgs e)
        {
            //If the form has not been open or has been closed. Initialize the Form.
            if (trackSalesForm == null || trackSalesForm.IsDisposed)
            {
                trackSalesForm = new TrackSalesForm();
                trackSalesForm.MdiParent = this;
                trackSalesForm.WindowState = FormWindowState.Maximized;
                trackSalesForm.Show();
            }
            //If the form is minimized, maximise the Form.
            else if (trackSalesForm.WindowState == FormWindowState.Minimized)
            {
                trackSalesForm.WindowState = FormWindowState.Maximized;
            }
            //Bring the Form to the Front.
            trackSalesForm.BringToFront();
        }
    }
}

